// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning;

public sealed partial class ValidateRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Validates an anomaly detection job.
/// </para>
/// </summary>
public sealed partial class ValidateRequest : PlainRequest<ValidateRequestParameters>
{
	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.validate";

	[JsonInclude, JsonPropertyName("analysis_config")]
	public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfig? AnalysisConfig { get; set; }
	[JsonInclude, JsonPropertyName("analysis_limits")]
	public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimits? AnalysisLimits { get; set; }
	[JsonInclude, JsonPropertyName("data_description")]
	public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescription? DataDescription { get; set; }
	[JsonInclude, JsonPropertyName("description")]
	public string? Description { get; set; }
	[JsonInclude, JsonPropertyName("job_id")]
	public Elastic.Clients.Elasticsearch.Serverless.Id? JobId { get; set; }
	[JsonInclude, JsonPropertyName("model_plot")]
	public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfig? ModelPlot { get; set; }
	[JsonInclude, JsonPropertyName("model_snapshot_id")]
	public Elastic.Clients.Elasticsearch.Serverless.Id? ModelSnapshotId { get; set; }
	[JsonInclude, JsonPropertyName("model_snapshot_retention_days")]
	public long? ModelSnapshotRetentionDays { get; set; }
	[JsonInclude, JsonPropertyName("results_index_name")]
	public Elastic.Clients.Elasticsearch.Serverless.IndexName? ResultsIndexName { get; set; }
}

/// <summary>
/// <para>
/// Validates an anomaly detection job.
/// </para>
/// </summary>
public sealed partial class ValidateRequestDescriptor<TDocument> : RequestDescriptor<ValidateRequestDescriptor<TDocument>, ValidateRequestParameters>
{
	internal ValidateRequestDescriptor(Action<ValidateRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

	public ValidateRequestDescriptor()
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.validate";

	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfig? AnalysisConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor<TDocument> AnalysisConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor<TDocument>> AnalysisConfigDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimits? AnalysisLimitsValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor AnalysisLimitsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor> AnalysisLimitsDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescription? DataDescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor<TDocument> DataDescriptionDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor<TDocument>> DataDescriptionDescriptorAction { get; set; }
	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Id? JobIdValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfig? ModelPlotValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor<TDocument> ModelPlotDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor<TDocument>> ModelPlotDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Id? ModelSnapshotIdValue { get; set; }
	private long? ModelSnapshotRetentionDaysValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexName? ResultsIndexNameValue { get; set; }

	public ValidateRequestDescriptor<TDocument> AnalysisConfig(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfig? analysisConfig)
	{
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigValue = analysisConfig;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> AnalysisConfig(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor<TDocument> descriptor)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> AnalysisConfig(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor<TDocument>> configure)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> AnalysisLimits(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimits? analysisLimits)
	{
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsValue = analysisLimits;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> AnalysisLimits(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor descriptor)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> AnalysisLimits(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor> configure)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> DataDescription(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescription? dataDescription)
	{
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionValue = dataDescription;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> DataDescription(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor<TDocument> descriptor)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> DataDescription(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor<TDocument>> configure)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> JobId(Elastic.Clients.Elasticsearch.Serverless.Id? jobId)
	{
		JobIdValue = jobId;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> ModelPlot(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfig? modelPlot)
	{
		ModelPlotDescriptor = null;
		ModelPlotDescriptorAction = null;
		ModelPlotValue = modelPlot;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> ModelPlot(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor<TDocument> descriptor)
	{
		ModelPlotValue = null;
		ModelPlotDescriptorAction = null;
		ModelPlotDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> ModelPlot(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor<TDocument>> configure)
	{
		ModelPlotValue = null;
		ModelPlotDescriptor = null;
		ModelPlotDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> ModelSnapshotId(Elastic.Clients.Elasticsearch.Serverless.Id? modelSnapshotId)
	{
		ModelSnapshotIdValue = modelSnapshotId;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> ModelSnapshotRetentionDays(long? modelSnapshotRetentionDays)
	{
		ModelSnapshotRetentionDaysValue = modelSnapshotRetentionDays;
		return Self;
	}

	public ValidateRequestDescriptor<TDocument> ResultsIndexName(Elastic.Clients.Elasticsearch.Serverless.IndexName? resultsIndexName)
	{
		ResultsIndexNameValue = resultsIndexName;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AnalysisConfigDescriptor is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigDescriptor, options);
		}
		else if (AnalysisConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor<TDocument>(AnalysisConfigDescriptorAction), options);
		}
		else if (AnalysisConfigValue is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigValue, options);
		}

		if (AnalysisLimitsDescriptor is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsDescriptor, options);
		}
		else if (AnalysisLimitsDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor(AnalysisLimitsDescriptorAction), options);
		}
		else if (AnalysisLimitsValue is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsValue, options);
		}

		if (DataDescriptionDescriptor is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionDescriptor, options);
		}
		else if (DataDescriptionDescriptorAction is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor<TDocument>(DataDescriptionDescriptorAction), options);
		}
		else if (DataDescriptionValue is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (JobIdValue is not null)
		{
			writer.WritePropertyName("job_id");
			JsonSerializer.Serialize(writer, JobIdValue, options);
		}

		if (ModelPlotDescriptor is not null)
		{
			writer.WritePropertyName("model_plot");
			JsonSerializer.Serialize(writer, ModelPlotDescriptor, options);
		}
		else if (ModelPlotDescriptorAction is not null)
		{
			writer.WritePropertyName("model_plot");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor<TDocument>(ModelPlotDescriptorAction), options);
		}
		else if (ModelPlotValue is not null)
		{
			writer.WritePropertyName("model_plot");
			JsonSerializer.Serialize(writer, ModelPlotValue, options);
		}

		if (ModelSnapshotIdValue is not null)
		{
			writer.WritePropertyName("model_snapshot_id");
			JsonSerializer.Serialize(writer, ModelSnapshotIdValue, options);
		}

		if (ModelSnapshotRetentionDaysValue.HasValue)
		{
			writer.WritePropertyName("model_snapshot_retention_days");
			writer.WriteNumberValue(ModelSnapshotRetentionDaysValue.Value);
		}

		if (ResultsIndexNameValue is not null)
		{
			writer.WritePropertyName("results_index_name");
			JsonSerializer.Serialize(writer, ResultsIndexNameValue, options);
		}

		writer.WriteEndObject();
	}
}

/// <summary>
/// <para>
/// Validates an anomaly detection job.
/// </para>
/// </summary>
public sealed partial class ValidateRequestDescriptor : RequestDescriptor<ValidateRequestDescriptor, ValidateRequestParameters>
{
	internal ValidateRequestDescriptor(Action<ValidateRequestDescriptor> configure) => configure.Invoke(this);

	public ValidateRequestDescriptor()
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.validate";

	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfig? AnalysisConfigValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor AnalysisConfigDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor> AnalysisConfigDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimits? AnalysisLimitsValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor AnalysisLimitsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor> AnalysisLimitsDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescription? DataDescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor DataDescriptionDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor> DataDescriptionDescriptorAction { get; set; }
	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Id? JobIdValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfig? ModelPlotValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor ModelPlotDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor> ModelPlotDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Id? ModelSnapshotIdValue { get; set; }
	private long? ModelSnapshotRetentionDaysValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexName? ResultsIndexNameValue { get; set; }

	public ValidateRequestDescriptor AnalysisConfig(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfig? analysisConfig)
	{
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigValue = analysisConfig;
		return Self;
	}

	public ValidateRequestDescriptor AnalysisConfig(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor descriptor)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptorAction = null;
		AnalysisConfigDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor AnalysisConfig(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor> configure)
	{
		AnalysisConfigValue = null;
		AnalysisConfigDescriptor = null;
		AnalysisConfigDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor AnalysisLimits(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimits? analysisLimits)
	{
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsValue = analysisLimits;
		return Self;
	}

	public ValidateRequestDescriptor AnalysisLimits(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor descriptor)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptorAction = null;
		AnalysisLimitsDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor AnalysisLimits(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor> configure)
	{
		AnalysisLimitsValue = null;
		AnalysisLimitsDescriptor = null;
		AnalysisLimitsDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor DataDescription(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescription? dataDescription)
	{
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionValue = dataDescription;
		return Self;
	}

	public ValidateRequestDescriptor DataDescription(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor descriptor)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptorAction = null;
		DataDescriptionDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor DataDescription(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor> configure)
	{
		DataDescriptionValue = null;
		DataDescriptionDescriptor = null;
		DataDescriptionDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	public ValidateRequestDescriptor JobId(Elastic.Clients.Elasticsearch.Serverless.Id? jobId)
	{
		JobIdValue = jobId;
		return Self;
	}

	public ValidateRequestDescriptor ModelPlot(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfig? modelPlot)
	{
		ModelPlotDescriptor = null;
		ModelPlotDescriptorAction = null;
		ModelPlotValue = modelPlot;
		return Self;
	}

	public ValidateRequestDescriptor ModelPlot(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor descriptor)
	{
		ModelPlotValue = null;
		ModelPlotDescriptorAction = null;
		ModelPlotDescriptor = descriptor;
		return Self;
	}

	public ValidateRequestDescriptor ModelPlot(Action<Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor> configure)
	{
		ModelPlotValue = null;
		ModelPlotDescriptor = null;
		ModelPlotDescriptorAction = configure;
		return Self;
	}

	public ValidateRequestDescriptor ModelSnapshotId(Elastic.Clients.Elasticsearch.Serverless.Id? modelSnapshotId)
	{
		ModelSnapshotIdValue = modelSnapshotId;
		return Self;
	}

	public ValidateRequestDescriptor ModelSnapshotRetentionDays(long? modelSnapshotRetentionDays)
	{
		ModelSnapshotRetentionDaysValue = modelSnapshotRetentionDays;
		return Self;
	}

	public ValidateRequestDescriptor ResultsIndexName(Elastic.Clients.Elasticsearch.Serverless.IndexName? resultsIndexName)
	{
		ResultsIndexNameValue = resultsIndexName;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AnalysisConfigDescriptor is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigDescriptor, options);
		}
		else if (AnalysisConfigDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigDescriptor(AnalysisConfigDescriptorAction), options);
		}
		else if (AnalysisConfigValue is not null)
		{
			writer.WritePropertyName("analysis_config");
			JsonSerializer.Serialize(writer, AnalysisConfigValue, options);
		}

		if (AnalysisLimitsDescriptor is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsDescriptor, options);
		}
		else if (AnalysisLimitsDescriptorAction is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimitsDescriptor(AnalysisLimitsDescriptorAction), options);
		}
		else if (AnalysisLimitsValue is not null)
		{
			writer.WritePropertyName("analysis_limits");
			JsonSerializer.Serialize(writer, AnalysisLimitsValue, options);
		}

		if (DataDescriptionDescriptor is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionDescriptor, options);
		}
		else if (DataDescriptionDescriptorAction is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescriptionDescriptor(DataDescriptionDescriptorAction), options);
		}
		else if (DataDescriptionValue is not null)
		{
			writer.WritePropertyName("data_description");
			JsonSerializer.Serialize(writer, DataDescriptionValue, options);
		}

		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (JobIdValue is not null)
		{
			writer.WritePropertyName("job_id");
			JsonSerializer.Serialize(writer, JobIdValue, options);
		}

		if (ModelPlotDescriptor is not null)
		{
			writer.WritePropertyName("model_plot");
			JsonSerializer.Serialize(writer, ModelPlotDescriptor, options);
		}
		else if (ModelPlotDescriptorAction is not null)
		{
			writer.WritePropertyName("model_plot");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfigDescriptor(ModelPlotDescriptorAction), options);
		}
		else if (ModelPlotValue is not null)
		{
			writer.WritePropertyName("model_plot");
			JsonSerializer.Serialize(writer, ModelPlotValue, options);
		}

		if (ModelSnapshotIdValue is not null)
		{
			writer.WritePropertyName("model_snapshot_id");
			JsonSerializer.Serialize(writer, ModelSnapshotIdValue, options);
		}

		if (ModelSnapshotRetentionDaysValue.HasValue)
		{
			writer.WritePropertyName("model_snapshot_retention_days");
			writer.WriteNumberValue(ModelSnapshotRetentionDaysValue.Value);
		}

		if (ResultsIndexNameValue is not null)
		{
			writer.WritePropertyName("results_index_name");
			JsonSerializer.Serialize(writer, ResultsIndexNameValue, options);
		}

		writer.WriteEndObject();
	}
}